package com.web.domain;

import java.io.Serializable;

/**
 * Created by xukk on 2017/6/7.
 */
public class WebResponse<T> implements Serializable {
    public static String create_fail="创建失败!";
    public static String create_success="创建成功!";
    public static String operation_fail="操作失败!";
    public static String operation_success="操作成功!";
    public static String null_object="操作对象不存在!";
    private String info;
    private String status;
    private T data;

    public WebResponse() {
    }

    public static WebResponse ok(String info){
        WebResponse webResponse=new WebResponse();
        webResponse.setStatus("y");
        webResponse.setInfo(info);
        return webResponse;
    }
    public static WebResponse fail(String info){
        WebResponse webResponse=new WebResponse();
        webResponse.setStatus("n");
        webResponse.setInfo(info);
        return webResponse;
    }
    public static WebResponse ok(String info,Object data){
        WebResponse webResponse=new WebResponse();
        webResponse.setStatus("y");
        webResponse.setInfo(info);
        webResponse.setData(data);
        return webResponse;
    }
    public static WebResponse fail(String info,Object data){
        WebResponse webResponse=new WebResponse();
        webResponse.setStatus("n");
        webResponse.setInfo(info);
        webResponse.setData(data);
        return webResponse;
    }
    public WebResponse addData(T data){
        this.setData(data);
        return this;
    }
    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public String getInfo() {
        return info;
    }

    public void setInfo(String info) {
        this.info = info;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public WebResponse(String status, String info) {
        this.info = info;
        this.status = status;
    }

}
